
#include "octahedron.h"

Octahedron :: Octahedron()
{
	Octahedron (this->Size());
}

Octahedron :: Octahedron (float _size) : Polyhedra(_size)
{
	Octahedron (_size, i, r);
}

Octahedron :: Octahedron (float _size, int _i, float _r) :
	Polyhedra (_size, _i, _r)
{
	num_pts = 6;
	p = new Point[6];
	SetPoint (_size);
}

Octahedron :: ~Octahedron()
{
	Polyhedra::~Polyhedra();
	if (p)
		delete p;
}

void Octahedron :: SetPoint (float _size)
{
	Polyhedra :: SetPoint (_size);

	float a = size*(float)( 1.0f / (1.5 * sqrt(2.0)) );
	float b = size*(float)( 1.0f / 1.5 );

	p[0].SetPoint (-a*size, 0.0f, a*size);
	p[1].SetPoint (-a*size, 0.0f, -a*size);
	p[2].SetPoint (0.0f, b*size, 0.0f);
	p[3].SetPoint (a*size, 0.0f, -a*size);
	p[4].SetPoint (a*size, 0.0f, a*size);
	p[5].SetPoint (0.0f, -b*size, 0.0f);
}

void Octahedron :: _Draw (Point* pts)
{
	DrawFace (pts[0], pts[1], pts[2]);
	DrawFace (pts[1], pts[3], pts[2]);
	DrawFace (pts[3], pts[4], pts[2]);
	DrawFace (pts[4], pts[0], pts[2]);
	DrawFace (pts[3], pts[1], pts[5]);
	DrawFace (pts[1], pts[0], pts[5]);
	DrawFace (pts[4], pts[3], pts[5]);
	DrawFace (pts[0], pts[4], pts[5]);
}
